home *** CD-ROM | disk | FTP | other *** search
/ Chip 1996 April / CHIP 1996 aprilis (CD06).zip / CHIP_CD06.ISO / szgyt / hello.txt < prev    next >
Lisp/Scheme  |  1996-03-20  |  4KB  |  187 lines

  1. A programozó életútja
  2.  
  3. Az alábbi példákon nyomon követhetjük a programozó szakmai fejlôdésének
  4. állomásait. Lássuk tehát, hogyan készíti el a klasszikus "Hello Word"
  5. programot, életének különbözô szakaszaiban:
  6.  
  7. Gimnazista
  8.  
  9.      10 PRINT "HELLO WORLD"
  10.      20 END
  11.  
  12. Elsôs egyetemista
  13.  
  14.      program Hello(input, output)
  15.        begin
  16.          writeln('Hello World')
  17.        end.
  18.  
  19. Utolsóéves egyetemista
  20.  
  21.      (defun hello
  22.        (print
  23.          (cons 'Hello (list 'World))))
  24.  
  25. Kezdô profi
  26.  
  27.      #include <stdio.h>
  28.      void main(void)
  29.      { char *message[] = {"Hello ", "World"};
  30.        int i;
  31.         for(i = 0; i< 2; ++i)
  32.         printf("%s", message[i]);
  33.         printf("\n");
  34.   }
  35.  
  36. Rafinált profi
  37.  
  38.      #include <iostream.h>
  39.      #include <string.h>
  40.  
  41.       class string
  42.       {
  43.       private:
  44.         int size;
  45.         char *ptr;
  46.  
  47.       public:
  48.         string() : size(0), ptr(new char('\0')) {}
  49.  
  50.         string(const string &s) : size(s.size)
  51.         {
  52.           ptr = new char[size + 1];
  53.           strcpy(ptr, s.ptr);
  54.         }
  55.  
  56.         ~string()
  57.         {
  58.           delete [] ptr;
  59.         }
  60.  
  61.         friend ostream &operator <<(ostream &, const string &);
  62.         string &operator=(const char *);
  63.       };
  64.  
  65.       ostream &operator<<(ostream &stream, const string &s)
  66.       {
  67.         return(stream << s.ptr);
  68.       }
  69.  
  70.       string &string::operator=(const char *chrs)
  71.       {
  72.         if (this != &chrs)
  73.         {
  74.           delete [] ptr;
  75.          size = strlen(chrs);
  76.           ptr = new char[size + 1];
  77.           strcpy(ptr, chrs);
  78.         }
  79.         return(*this);
  80.       }
  81.  
  82.       int main()
  83.       {
  84.         string str;
  85.  
  86.         str = "Hello World";
  87.         cout << str << endl;
  88.  
  89.         return(0);
  90.       }
  91.  
  92. Mesterprogramozó
  93.  
  94.       [
  95.       uuid(2573F8F4-CFEE-101A-9A9F-00AA00342820)
  96.       ]
  97.       library LHello
  98.       {
  99.           // bring in the master library
  100.           importlib("actimp.tlb");
  101.           importlib("actexp.tlb");
  102.  
  103.           // bring in my interfaces
  104.           #include "pshlo.idl"
  105.  
  106.           [
  107.           uuid(2573F8F5-CFEE-101A-9A9F-00AA00342820)
  108.           ]
  109.           cotype THello
  110.        {
  111.        interface IHello;
  112.        interface IPersistFile;
  113.        };
  114.       };
  115.  
  116.       [
  117.       exe,
  118.       uuid(2573F890-CFEE-101A-9A9F-00AA00342820)
  119.       ]
  120.       module CHelloLib
  121.       {
  122.  
  123.           // some code related header files
  124.           importheader(
  125. Kezdô buherátor
  126.  
  127.     #!/usr/local/bin/perl
  128.       $msg="Hello, world.\n";
  129.       if ($#ARGV = 0) {
  130.         while(defined($arg=shift(@ARGV))) {
  131.           $outfilename = $arg;
  132.           open(FILE, "" . $outfilename) ││ die "Can't write $arg: $!\n";
  133.           print (FILE $msg);
  134.           close(FILE) ││ die "Can't close $arg: $!\n";
  135.         }
  136.       } else {
  137.         print ($msg);
  138.       }
  139.       1;
  140.  
  141. Tapasztalt buherátor
  142.  
  143.  
  144.       #include
  145.  
  146. Rafinált buherátor
  147.  
  148.      % cc -o a.out ~/src/misc/hw/hw.c
  149.      % a.out
  150.  
  151. Nagymester buherátor
  152.  
  153.      % cat
  154.        Hello, world.
  155.        ^D
  156.  
  157. Ujdonsült menedzser
  158.  
  159.      10 PRINT "HELLO WORLD"
  160.      20 END
  161.  
  162. Középvezetô menedzser
  163.  
  164.      mail -s "Hello, world." bob@b12
  165.      Bob, tudnal nekem holnapra irni egy programot,
  166.      ami kiirja a kepernyore, hogy "Hello word"?
  167.      Koszi!
  168.      ^D
  169.  
  170. Vezetô menedzser
  171.  
  172.      % zmail jim
  173.        Delutanra szuksegem van egy "Hello Word" programra.
  174.  
  175. Vezérigazgató
  176.  
  177. % letter
  178.   letter: Command not found.
  179. % mail To: ^X
  180. ^F ^C
  181. % help mail
  182. help: Command not found.
  183. % faszom!
  184. !: Event unrecognized
  185. % logout
  186.  
  187.